/*
 * @lc app=leetcode.cn id=242 lang=javascript
 *
 * [242] 有效的字母异位词
 */

// @lc code=start
/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var isAnagram = function (s, t) {
  if(s.length!==t.length) return false
  const charList = new Array(26).fill(0)
  const base = 'a'.charCodeAt()
  for (let i of s) {
    charList[i.charCodeAt()-base]++
  }
  for (let i of t) {
    if(!charList[i.charCodeAt()-base]) return false
    charList[i.charCodeAt()-base]--
  }
  return true
};
// @lc code=end

